﻿namespace Shared.Service.EventBus
{
    public class IgnoredBus
    {
        //private readonly BusConfig _busConfig;
        //private IBusControl _bus;

        //public DistributedBus(BusConfig busConfig)
        //{
        //    _busConfig = busConfig;
        //}

        //public void Start(IServiceCollection services, IApplicationLifetime applicationLifetime)
        //{
        //    if (!_busConfig.IsEnabled)
        //        return;

        //    _bus = MassTransit.Bus.Factory.CreateUsingRabbitMq(cfg =>
        //    {
        //        cfg.Host(_busConfig.RabbitMqUri, h =>
        //        {
        //            h.Username(_busConfig.UserName);
        //            h.Password(_busConfig.Password);
        //        });
        //    });

        //    services.AddSingleton<IEventBus>(new DistributedEventBus(_bus, _busConfig));

        //    applicationLifetime.ApplicationStarted.Register(_bus.Start);
        //    applicationLifetime.ApplicationStopped.Register(_bus.Stop);
        //}

        //public void Start(
        //    IServiceCollection services,
        //    IApplicationLifetime applicationLifetime,
        //    Action<IRabbitMqBusFactoryConfigurator> factoryConfigurator)
        //{
        //    if (!_busConfig.IsEnabled)
        //        return;

        //    _bus = MassTransit.Bus.Factory.CreateUsingRabbitMq(cfg =>
        //    {
        //        cfg.Host(_busConfig.RabbitMqUri, h =>
        //        {
        //            h.Username(_busConfig.UserName);
        //            h.Password(_busConfig.Password);
        //        });

        //        factoryConfigurator(cfg);
        //    });

        //    services.AddSingleton<IEventBus>(new DistributedEventBus(_bus, _busConfig));

        //    applicationLifetime.ApplicationStarted.Register(_bus.Start);
        //    applicationLifetime.ApplicationStopped.Register(_bus.Stop);
        //}
    }
}
